<!DOCTYPE html>
<html class="has-navbar-fixed-top">
<head>
    <meta charset="utf-8">
<title>PostgreSQL常用命令记录 - wanzixin</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.css">


<link href="/Study/zh-cn/PostgreSQL%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E8%AE%B0%E5%BD%95/" rel="alternate" hreflang="en" />
    


<meta name="description" content="">





    <meta name="description" content="PostgreSQL版本是12.2，psql 是 PostgreSQL 中的一个命令行交互式客户端工具，它允许你交互地键入 SQL 命令，然后把它们发送给 PostgreSQL 服务器，再显示 SQL 或命令的结果。输入的内容允许来自一个文件，此外它还提供了一些元命令和多种类似 shell 的特性来实现书写脚本，以及对大量任务的自动化工作。约定[]表示其中的内容可选，{}和|表示需选择一个候选，…">
<meta property="og:type" content="article">
<meta property="og:title" content="PostgreSQL常用命令记录">
<meta property="og:url" content="https://wanzixin.github.io/Study/zh-cn/PostgreSQL%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E8%AE%B0%E5%BD%95/index.html">
<meta property="og:site_name" content="wanzixin">
<meta property="og:description" content="PostgreSQL版本是12.2，psql 是 PostgreSQL 中的一个命令行交互式客户端工具，它允许你交互地键入 SQL 命令，然后把它们发送给 PostgreSQL 服务器，再显示 SQL 或命令的结果。输入的内容允许来自一个文件，此外它还提供了一些元命令和多种类似 shell 的特性来实现书写脚本，以及对大量任务的自动化工作。约定[]表示其中的内容可选，{}和|表示需选择一个候选，…">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-09-12T07:00:15.000Z">
<meta property="article:modified_time" content="2021-05-30T14:23:35.882Z">
<meta property="article:author" content="wanzixin">
<meta name="twitter:card" content="summary">





<link rel="icon" href="/favicon.png">


<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Ovo|Source+Code+Pro">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css">


<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/lightgallery/1.6.8/css/lightgallery.min.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/justifiedGallery/3.6.5/css/justifiedGallery.min.css">


<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-light.min.css">


<link rel="stylesheet" href="/css/style.css">


<script defer src="//use.fontawesome.com/releases/v5.0.8/js/all.js"></script>


    
    
    
    
    
    
    
    
    
    

    


<meta name="generator" content="Hexo 5.4.0"></head>
<body>
    
<nav class="navbar is-transparent is-fixed-top navbar-main" role="navigation" aria-label="main navigation">
    <div class="container">
        <div class="navbar-brand">
            <a class="navbar-item navbar-logo" href="/zh-cn">
                
                    
                    wanzixin
                    
                
            </a>
            <div class="navbar-burger">
                <span></span>
                <span></span>
                <span></span>
            </div>
        </div>
        
        <div class="navbar-menu navbar-start">
            
            <a class="navbar-item "
               href="/archives">Archives</a>
            
            <a class="navbar-item "
               href="/categories">Categories</a>
            
            <a class="navbar-item "
               href="/categories/Diary">Diary</a>
            
            <a class="navbar-item "
               href="/categories/Gallery">Gallery</a>
            
            <a class="navbar-item "
               href="/categories/Study">Study</a>
            
            <a class="navbar-item "
               href="/categories/Item">Item</a>
            
            <a class="navbar-item "
               href="/about">About</a>
            
        </div>
        
        <div class="navbar-menu navbar-end">
            
            <a class="navbar-item search" title="搜索" href="javascript:;">
                <i class="fas fa-search"></i>
            </a>
            
            
            <div class="navbar-item is-hoverable has-dropdown is-hidden-mobile is-hidden-tablet-only toc">
                <a class="navbar-item" title="目录">
                    <i class="fa fa-list"></i>
                </a>
                <div class="navbar-dropdown is-right">
                    
                    
                    
                    
                    <a class="navbar-item" href="#角色">1&nbsp;&nbsp;<b>角色</b></a>
                    
                    
                    
                    <a class="navbar-item" href="#登录">1.1&nbsp;&nbsp;登录</a>
                    
                    
                    
                    <a class="navbar-item" href="#创建角色">1.2&nbsp;&nbsp;创建角色</a>
                    
                    
                    
                    <a class="navbar-item" href="#修改角色权限">1.3&nbsp;&nbsp;修改角色权限</a>
                    
                    
                    
                    <a class="navbar-item" href="#删除角色">1.4&nbsp;&nbsp;删除角色</a>
                    
                    
                    <hr class="navbar-divider">
                    
                    
                    <a class="navbar-item" href="#数据库">2&nbsp;&nbsp;<b>数据库</b></a>
                    
                    
                    
                    <a class="navbar-item" href="#创建数据库">2.1&nbsp;&nbsp;创建数据库</a>
                    
                    
                    
                    <a class="navbar-item" href="#删除数据库">2.2&nbsp;&nbsp;删除数据库</a>
                    
                    
                    <hr class="navbar-divider">
                    
                    
                    <a class="navbar-item" href="#表">3&nbsp;&nbsp;<b>表</b></a>
                    
                    
                    
                    <a class="navbar-item" href="#创建表">3.1&nbsp;&nbsp;创建表</a>
                    
                    
                    
                    <a class="navbar-item" href="#删除表">3.2&nbsp;&nbsp;删除表</a>
                    
                    
                    <hr class="navbar-divider">
                    
                    
                    <a class="navbar-item" href="#其余常用命令">4&nbsp;&nbsp;<b>其余常用命令</b></a>
                    
                </div>
            </div>
            
            
            <a class="navbar-item" title="GitHub" target="_blank" rel="noopener" href="https://github.com/wanzixin">
                
                <i class="fab fa-github"></i>
                
            </a>
               
            
        </div>
    </div>
</nav>

    <section class="section">
    <div class="container">
    <article class="article content gallery" itemscope itemprop="blogPost">
    <h1 class="article-title is-size-3 is-size-4-mobile" itemprop="name">
        
            PostgreSQL常用命令记录
        
    </h1>
    <div class="article-meta columns is-variable is-1 is-multiline is-mobile is-size-7-mobile">
        <span class="column is-narrow">
            
                <span>9月 12 2020</span>
            
        </span>
        
        <span class="column is-narrow article-category">
            <i class="far fa-folder"></i>
            <a class="article-category-link" href="/zh-cn/categories/Study/">Study</a>
        </span>
        
        
        <span class="column is-narrow">
            
            
            10 分钟 读完 (约 1442 字)
        </span>
        
    </div>
    <div class="article-entry is-size-6-mobile" itemprop="articleBody">
    
        <html><head></head><body><p>PostgreSQL版本是12.2，<strong>psql</strong> 是 PostgreSQL 中的一个命令行交互式客户端工具，它允许你交互地键入 SQL 命令，然后把它们发送给 PostgreSQL 服务器，再显示 SQL 或命令的结果。输入的内容允许来自一个文件，此外它还提供了一些元命令和多种类似 shell 的特性来实现书写脚本，以及对大量任务的自动化工作。约定[]表示其中的内容可选，{}和|表示需选择一个候选，…表示前面的元素可以重复。中文官方链接，地址<a target="_blank" rel="noopener" href="http://www.postgres.cn/docs/12/index.html">指路</a>。<span id="more"></span></p>
<h2 id="角色"><a href="#角色" class="headerlink" title="角色"></a>角色</h2><h3 id="登录"><a href="#登录" class="headerlink" title="登录"></a>登录</h3><ol>
<li>使用用默认超级用户<code>postgres</code>登录，输入<code>psql -U postgres</code>，再输入安装时设置的超级用户密码，回车即可登入。 </li>
<li>假设现有拥有登录权限用户为user和数据库exampledb，则登录命令为<code>psql -U user -d exampledb</code>，-U参数指定登录用户，-d参数指定待操作的数据库。</li>
<li>假设现有数据库exampledb和登录权限的用户为user，且<strong>user正好为当前操作系统用户</strong>，此时可以省略-U参数，登录命令为<code>psql -d exampledb</code>。</li>
</ol>
<h3 id="创建角色"><a href="#创建角色" class="headerlink" title="创建角色"></a>创建角色</h3><ol>
<li><p>在超级用户登录状态下，创建新角色，<code>CREATE ROLE name</code>，创建名称为name的角色，没有任何权限。</p>
</li>
<li><p>在超级用户登录状态下，创建新角色，<code>CREATE USER name</code>，创建名称为name的角色，除了登录权限外，没有任何权限，该行命令等价于<code>CREATE ROLE name LOGIN</code>。</p>
</li>
<li><p>在超级用户登录状态下，创建一个新超级用户，使用<code>CREATE ROLE name SUPERUSER</code>。一个数据库超级用户除了登录会绕开所有的权限检查，<strong>使用超级用户操作是危险的操作，推荐用受限的角色完成大部分工作</strong>。</p>
</li>
<li><p>创建超级用户的详细命令以及对应的解释如下。</p>
</li>
</ol>
<figure class="highlight sql hljs"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">CREATE</span> ROLE name [ [ <span class="hljs-keyword">WITH</span> ] option [ ... ] ]<br><br><span class="hljs-keyword">where</span> option：<br><br>      SUPERUSER <span class="hljs-operator">|</span> NOSUPERUSER <span class="hljs-comment">--该角色是否是超级用户</span><br>    <span class="hljs-operator">|</span> CREATEDB <span class="hljs-operator">|</span> NOCREATEDB <span class="hljs-comment">--该角色是否可以创建数据库</span><br>    <span class="hljs-operator">|</span> CREATEROLE <span class="hljs-operator">|</span> NOCREATEROLE <span class="hljs-comment">--该角色是否可以创建新角色</span><br>    <span class="hljs-operator">|</span> INHERIT <span class="hljs-operator">|</span> NOINHERIT <span class="hljs-comment">--该角色是否继承自其他角色</span><br>    <span class="hljs-operator">|</span> LOGIN <span class="hljs-operator">|</span> NOLOGIN <span class="hljs-comment">--该角色是否具有登录权限</span><br>    <span class="hljs-operator">|</span> REPLICATION <span class="hljs-operator">|</span> NOREPLICATION <span class="hljs-comment">--决定一个角色是否为复制角色，能以复制模式（物理复制或者逻辑复制）连接到服务器以及创建或者删除复制槽，这是非常高特权，默认为否</span><br>    <span class="hljs-operator">|</span> BYPASSRLS <span class="hljs-operator">|</span> NOBYPASSRLS <span class="hljs-comment">--是否一个角色可以绕过每一条行级安全性（RLS）策略</span><br>    <span class="hljs-operator">|</span> CONNECTION LIMIT connlimit <span class="hljs-comment">--如果角色能登录，这指定该角色能建立多少并发连接</span><br>    <span class="hljs-operator">|</span> [ ENCRYPTED ] PASSWORD <span class="hljs-string">'password'</span> <span class="hljs-operator">|</span> PASSWORD <span class="hljs-keyword">NULL</span> <span class="hljs-comment">--设置角色的口令（口令只对具有LOGIN属性的角色有用，如果没有指定口令，口令将被设置为空并且该用户的口令认证总是会失败。也可以用PASSWORD NULL显式地写出一个空口令。</span><br>    <span class="hljs-operator">|</span> VALID UNTIL <span class="hljs-string">'timestamp'</span> <span class="hljs-comment">--设置一个日期和时间，在该时间点之后角色的口令将会失效</span><br>    <span class="hljs-operator">|</span> <span class="hljs-keyword">IN</span> ROLE role_name [, ...] <span class="hljs-comment">--IN ROLE子句列出一个或多个现有的角色，新角色将被立即作为新成员加入到这些角色中</span><br>    <span class="hljs-operator">|</span> <span class="hljs-keyword">IN</span> <span class="hljs-keyword">GROUP</span> role_name [, ...] <span class="hljs-comment">--是IN ROLE的废弃写法</span><br>    <span class="hljs-operator">|</span> ROLE role_name [, ...] <span class="hljs-comment">--ROLE子句列出一个或者多个现有角色，它们会被自动作为成员加入到新角色中</span><br>    <span class="hljs-operator">|</span> ADMIN role_name [, ...] <span class="hljs-comment">--略</span><br>    <span class="hljs-operator">|</span> <span class="hljs-keyword">USER</span> role_name [, ...] <span class="hljs-comment">--是ROLE子句的废弃写法</span><br>    <span class="hljs-operator">|</span> SYSID uid <span class="hljs-comment">--向后兼容</span><br></code></pre></td></tr></tbody></table></figure>
<h3 id="修改角色权限"><a href="#修改角色权限" class="headerlink" title="修改角色权限"></a>修改角色权限</h3><p>在创建角色时未指定的权限，都可以在超级用户登录状态下得以修改，比如更改角色名称，更改/移除一个角色的口令，更改一个角色的失效日期，使角色具有创建数据库的权限等等。</p>
<figure class="highlight sql hljs"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-comment">--示例</span><br><span class="hljs-comment">--更改一个角色的口令</span><br><span class="hljs-keyword">ALTER</span> ROLE davide <span class="hljs-keyword">WITH</span> PASSWORD <span class="hljs-string">'hu8jmn3'</span>;<br><br><span class="hljs-comment">--移除一个角色的口令</span><br><span class="hljs-keyword">ALTER</span> ROLE davide <span class="hljs-keyword">WITH</span> PASSWORD <span class="hljs-keyword">NULL</span>;<br><br><span class="hljs-comment">--让一个角色能够创建新的数据库：</span><br><span class="hljs-keyword">ALTER</span> ROLE davide CREATEDB;<br><br><span class="hljs-comment">--更改一个口令的失效日期，指定该口令应该在2020年5月4日中午（在一个比UTC快 1 小时的时区）过期</span><br><span class="hljs-keyword">ALTER</span> ROLE davide VALID UNTIL <span class="hljs-string">'May 4 12:00:00 2020 +1'</span>;<br><br><span class="hljs-comment">--更改一个角色的名称</span><br><span class="hljs-keyword">ALTER</span> ROLE davide RENAME <span class="hljs-keyword">TO</span> new_davide;<br></code></pre></td></tr></tbody></table></figure>

<p>完整的角色权限修改语句和参数，其中大部分与创建角色时的参数相同，含义也一致，<a target="_blank" rel="noopener" href="http://www.postgres.cn/docs/12/sql-alterrole.html">参考地址</a>。</p>
<h3 id="删除角色"><a href="#删除角色" class="headerlink" title="删除角色"></a>删除角色</h3><p>由于角色可以拥有数据库对象并且能持有访问其他对象的特权，删除一个角色 常常并非一次<code>DROP ROLE</code>就能解决。该用户所拥有的对象必须被删除或转移给其他角色。</p>
<figure class="highlight sql hljs"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">TABLE</span> bobs_table OWNER <span class="hljs-keyword">TO</span> alice;<br><span class="hljs-comment">--类似的数据完全安排给其他角色后</span><br><span class="hljs-keyword">DROP</span> ROLE davide;<br></code></pre></td></tr></tbody></table></figure>

<h2 id="数据库"><a href="#数据库" class="headerlink" title="数据库"></a>数据库</h2><h3 id="创建数据库"><a href="#创建数据库" class="headerlink" title="创建数据库"></a>创建数据库</h3><ol>
<li>超级用户或普通角色登录状态下，<code>CREATE DATABASE dbname</code>，创建数据库默认为当前登录用户所有。</li>
<li>超级用户或普通角色登录状态下，<code>CREATE DATABASE dbname OWNER rolename</code> ，创建数据库并指定数据库拥有者。</li>
</ol>
<h3 id="删除数据库"><a href="#删除数据库" class="headerlink" title="删除数据库"></a>删除数据库</h3><figure class="highlight sql hljs"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">DROP</span> DATABASE dbname;<br></code></pre></td></tr></tbody></table></figure>

<h2 id="表"><a href="#表" class="headerlink" title="表"></a>表</h2><h3 id="创建表"><a href="#创建表" class="headerlink" title="创建表"></a>创建表</h3><figure class="highlight sql hljs"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">DROP</span> <span class="hljs-keyword">TABLE</span> tablename;<br></code></pre></td></tr></tbody></table></figure>

<h3 id="删除表"><a href="#删除表" class="headerlink" title="删除表"></a>删除表</h3><figure class="highlight sql hljs"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql"><span class="hljs-keyword">DROP</span> <span class="hljs-keyword">TABLE</span> tablename;<br></code></pre></td></tr></tbody></table></figure>

<h2 id="其余常用命令"><a href="#其余常用命令" class="headerlink" title="其余常用命令"></a>其余常用命令</h2><p><code>\l</code>查看已经存在的数据库</p>
<p><code>\c dbname</code> 进入数据库</p>
<p><code>\d</code>查看所有表</p>
<p><code>\d tablename</code>查看指定表信息</p>
<p><code>\du</code>查看所有角色</p>
</body></html>
    
    </div>
    
    
    <div class="columns is-mobile is-multiline article-nav">
        <span class="column is-12-mobile is-half-desktop  article-nav-prev">
            
            <a href="/Study/Java/zh-cn/Java%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/">Java快速入门</a>
            
        </span>
        <span class="column is-12-mobile is-half-desktop  article-nav-next">
            
            <a href="/Item/zh-cn/Python%E4%B8%8BGDAL%E5%92%8COGR%E7%9A%84%E4%BD%BF%E7%94%A8/">Python下GDAL和OGR的使用</a>
            
        </span>
    </div>
    
</article>


<div class="sharebox">
    
<div class="sharethis-inline-share-buttons"></div>
<script type='text/javascript' src='//platform-api.sharethis.com/js/sharethis.js#property=608c1408daac690012507aa2&amp;product=sop' async='async'></script>

</div>



    </div>
</section>
    <footer class="footer">
    <div class="container">
        <div class="columns content">
            <div class="column is-narrow has-text-centered">
                &copy; 2021 wanzixin&nbsp;
                Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> & <a
                        target="_blank" rel="noopener" href="http://github.com/ppoffice/hexo-theme-minos">Minos</a>
            </div>
            <div class="column is-hidden-mobile"></div>

            
            <div class="column is-narrow">
                <div class="columns is-mobile is-multiline is-centered">
                
                    
                <a class="column is-narrow has-text-black" title="GitHub" target="_blank" rel="noopener" href="https://github.com/ppoffice/hexo-theme-minos">
                    
                    GitHub
                    
                </a>
                
                </div>
            </div>
            
            
<div class="column is-narrow has-text-centered">
    <div class="dropdown is-up is-right is-hoverable" style="margin-top: -0.2em;">
        <div class="dropdown-trigger">
            <button class="button is-small" aria-haspopup="true" aria-controls="dropdown-menu7">
                <span class="icon">
                    <i class="fas fa-globe"></i>
                </span>
                <span>简体中文</span>
                <span class="icon is-small">
            <i class="fas fa-angle-down" aria-hidden="true"></i>
          </span>
            </button>
        </div>
        <div class="dropdown-menu has-text-left" role="menu">
            <div class="dropdown-content">
            
                <a href="/Study/zh-cn/PostgreSQL%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E8%AE%B0%E5%BD%95/" class="dropdown-item">
                    English
                </a>
            
                <a href="/zh-cn/Study/zh-cn/PostgreSQL%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E8%AE%B0%E5%BD%95/" class="dropdown-item">
                    简体中文
                </a>
            
            </div>
        </div>
    </div>
</div>

        </div>
    </div>
</footer>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment-with-locales.min.js"></script>

<!-- test if the browser is outdated -->
<div id="outdated">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" target="_blank" rel="noopener" href="http://outdatedbrowser.com/">Update my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
</div>
<script src="//cdnjs.cloudflare.com/ajax/libs/outdated-browser/1.1.5/outdatedbrowser.min.js"></script>
<script>
    $(document).ready(function () {
        // plugin function, place inside DOM ready function
        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'flex'
        })
    });
</script>

<script>
    window.FontAwesomeConfig = {
        searchPseudoElements: true
    }
    moment.locale("zh-CN");
</script>


    
    
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<script>
    MathJax.Hub.Config({
        "HTML-CSS": {
            matchFontHeight: false
        },
        SVG: {
            matchFontHeight: false
        },
        CommonHTML: {
            matchFontHeight: false
        },
        tex2jax: {
            inlineMath: [
                ['$','$'],
                ['\\(','\\)']
            ]
        }
    });
</script>

    
    
    
    
<script src="//cdnjs.cloudflare.com/ajax/libs/lightgallery/1.6.8/js/lightgallery-all.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/justifiedGallery/3.6.5/js/jquery.justifiedGallery.min.js"></script>
<script>
    (function ($) {
        $(document).ready(function () {
            if (typeof($.fn.lightGallery) === 'function') {
                $('.article.gallery').lightGallery({ selector: '.gallery-item' });
            }
            if (typeof($.fn.justifiedGallery) === 'function') {
                $('.justified-gallery').justifiedGallery();
            }
        });
    })(jQuery);
</script>

    
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script>
    <style>
        .hljs {
            position: relative;
        }

        .hljs .clipboard-btn {
            float: right;
            color: #9a9a9a;
            background: none;
            border: none;
            cursor: pointer;
        }

        .hljs .clipboard-btn:hover {
          color: #8a8a8a;
        }

        .hljs > .clipboard-btn {
            display: none;
            position: absolute;
            right: 4px;
            top: 4px;
        }

        .hljs:hover > .clipboard-btn {
            display: inline;
        }

        .hljs > figcaption > .clipboard-btn {
            margin-right: 4px;
        }
    </style>
    <script>
      $(document).ready(function () {
        $('figure.hljs').each(function(i, figure) {
          var codeId = 'code-' + i;
          var code = figure.querySelector('.code');
          var copyButton = $('<button>Copy <i class="far fa-clipboard"></i></button>');
          code.id = codeId;
          copyButton.addClass('clipboard-btn');
          copyButton.attr('data-clipboard-target-id', codeId);

          var figcaption = figure.querySelector('figcaption');

          if (figcaption) {
            figcaption.append(copyButton[0]);
          } else {
            figure.prepend(copyButton[0]);
          }
        })

        var clipboard = new ClipboardJS('.clipboard-btn', {
          target: function(trigger) {
            return document.getElementById(trigger.getAttribute('data-clipboard-target-id'));
          }
        });
        clipboard.on('success', function(e) {
          e.clearSelection();
        })
      })
    </script>

    
    

    



<script src="/js/script.js"></script>


    
    <div class="searchbox ins-search">
    <div class="searchbox-mask"></div>
    <div class="searchbox-container ins-search-container">
        <div class="searchbox-input-wrapper">
            <input type="text" class="searchbox-input ins-search-input" placeholder="站内搜索" />
            <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="searchbox-result-wrapper ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: '文章',
                PAGES: '页面',
                CATEGORIES: '分类',
                TAGS: '标签',
                UNTITLED: '(无标题)',
            },
            CONTENT_URL: '/content.zh-cn.json',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>

<script src="/js/insight.js"></script>

    
</body>
</html>